<script setup>
import { ref } from 'vue';
import { doctorderListAPI } from '@/apis/doct';
  const props=defineProps({
	  type:{
		  type:Number,
	      default:2
	  }
  })
     
     const isnomore=ref(true)
     const loading=ref('loading')
     // 当前页
      const current=ref(1)
      // 一页多少条
     const pageSize=ref(5)
	 // 总条数
	const  total=ref(0)
     // 获取数据列表
     const doctorderlist=ref([])
     const getdoctorderlist=()=>{ 
     	doctorderListAPI({ 
     		type: props.type,
     		current: current.value,
     		pageSize:pageSize.value
       }).then((res)=>{
     		console.log(res);
			total.value=res.data.total
     		doctorderlist.value=[...doctorderlist.value,...res.data.rows]
		    loading.value='noMore'
     	})
     }
	 
	// 上拉 加载更多
	const refreshButton=(e)=>{
		   console.log(e);
		  // loading.value=current.value*pageSize.value<=total.value ?'More':'noMore'
	   if(current.value*pageSize.value<=total.value){
		     current.value++
		     getdoctorderlist()
			 // isnomore.value=true
		   }else{
		   	uni.showToast({
		   		title:'没有更多数据了',
		   		icon:'none'
		   	})
			loading.value='noMore'
		   }
	 }
	 
	 
	 
	 
	 // 删除
	 const deletes=(index)=>{
		    console.log(index);
			console.log('1');
	 }
	 
	const emit=defineEmits(['del'])
     getdoctorderlist()
</script>
<template>
  <scroll-view
    refresher-enabled
    refresher-background="#f6f6f6"
    class="uni-scroll-view"
    scroll-y
	@scrolltolower='refreshButton'
  >
    <view class="consult-list" >
      <view class="consult-list-item" v-for="item,index in doctorderlist">
        <view class="consult-header">
          <view class="label">
            <image
              class="doctor-avatar"
              src="/static/uploads/doctor-avatar.jpg"
            />
            <text>{{item.typeValue}}（自动分配医生）</text>
          </view>
          <text class="status color-1"> {{item.statusValue}}{{item.status}} </text>
        </view>

        <navigator
          class="consult-body"
          hover-class="none"
          url="/subpkg_consult/order_detail/index"
        >
          <uni-list :border="false">
            <uni-list-item
              :border="false"
              title=" 病情描述 "
            :right-text="item.illnessDesc "
            />
            <uni-list-item :border="false" title=" 价格 " :right-text="'¥'+item.payment" />
            <uni-list-item
              :border="false"
              title=" 创建时间 "
              :right-text="item.createTime"
            />
          </uni-list>
        </navigator>

        <view class="consult-footer" v-if="item.status==1">
          <button class="uni-button minor"> 取消订单 </button>
          <button class="uni-button"> 去支付 </button>
        </view> 
		<view class="consult-footer" v-if="item.status==2 ">
          <button class="uni-button minor"> 取消订单 </button>
          <button class="uni-button"> 继续咨询 </button>
        </view>
		<view class="consult-footer" v-if="item.status==3">
          <button class="uni-button minor"> 取消订单 </button>
          <button class="uni-button"> 继续咨询 </button>
        </view>
		<view class="consult-footer" v-if="item.status==4">
          <button class="uni-button minor"> 问诊记录 </button>
          <button class="uni-button" > 查看评论 </button>
		  <button class="uni-button"  @click='deletes(index)'> 删除订单 </button>
        </view>
		<view class="consult-footer" v-if="item.status== 5">
          <button class="uni-button"  type="warn"  @click='deletes(index)'> 删除订单 </button>
        </view>
		
      </view>
	  
      <!-- 加载状态 -->
      <uni-load-more
        :status="loading"
        color="#C3C3C5"
        :icon-size="16"
      />
    </view>
  </scroll-view>
</template>

<style lang="scss">
  // subpkg_consult/order_list/components/styles.scss
  .uni-scroll-view {
    height: calc(100vh - 50px);
    /* #ifdef H5 */
    height: calc(100vh - 94px);
    /* #endif */
    overflow: hidden;
    box-sizing: border-box;
    padding-top: 15rpx;
    padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  }
  
  .consult-list {
    padding: 15rpx 30rpx 30rpx;
  }
  
  .consult-list-item {
    // height: 715rpx;
    padding: 0 30rpx;
    margin-bottom: 30rpx;
    border-radius: 10rpx;
    background-color: #fff;
  
    .consult-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 100rpx;
      padding: 0 30rpx;
      margin: 0 -30rpx;
      font-size: 30rpx;
      border-bottom: 1rpx solid #f5f5f5;
  
      .label {
        display: flex;
        align-items: center;
        color: #000;
        font-weight: 500;
      }
  
      .doctor-avatar {
        width: 40rpx;
        height: 40rpx;
        margin-right: 10rpx;
        border-radius: 50%;
      }
  
      .status {
        color: #121826;
      }
  
      .color-1 {
        color: #f2994a;
      }
  
      .color-2 {
        color: #16c2a3;
      }
  
      .color-3 {
        color: #848484;
      }
    }
  
    .consult-body {
      padding: 20rpx 0;
    }
  
    :deep(.uni-list-item__container) {
      padding: 10rpx 0 !important;
    }
  
    :deep(.uni-list-item__content-title) {
      font-size: 28rpx !important;
      color: #c3c3c5 !important;
    }
  
    :deep(.uni-list-item__extra-text) {
      font-size: 28rpx !important;
      color: #333 !important;
    }
  
    :deep(.uni-list-item__extra) {
      width: 480rpx !important;
      justify-content: flex-start !important;
    }
  
    .consult-footer {
      display: flex;
      justify-content: flex-end;
      padding: 30rpx 0;
      border-top: 1rpx solid #f5f5f5;
  
      .uni-button {
        height: 60rpx;
        line-height: 60rpx;
        /* #ifdef MP */
        line-height: 59rpx;
        /* #endif */
        margin: 0 0 0 30rpx;
        font-size: 26rpx;
        color: #16c2a3;
        border: 1rpx solid #16c2a3;
        background-color: #fff;
  
        &.more {
          flex: 1;
          text-align: left;
          margin-left: 0;
          border-color: transparent;
          color: #979797;
          position: relative;
        }
  
        .list {
          position: absolute;
          left: 0;
          bottom: 75rpx;
          z-index: 99;
          width: 160rpx;
          text-align: center;
          padding: 10rpx 30rpx;
          border-radius: 10rpx;
          font-size: 28rpx;
          box-shadow: 0 0 30rpx rgba(50, 50, 51, 0.3);
          background-color: #fff;
  
          &::after {
            position: absolute;
            bottom: -28rpx;
            left: 30rpx;
            content: '';
            border-width: 14rpx;
            border-style: solid;
            border-color: #fff transparent transparent transparent;
          }
        }
  
        .list-item {
          padding: 10rpx 0;
          border-bottom: 1rpx solid #eee;
  
          &:last-child {
            border-bottom: none;
          }
        }
  
        &.minor {
          color: #3c3e42;
          border-color: #ededed;
          background-color: #fafafa;
        }
      }
    }
  }
  </style>